<?php

class devicecontroller extends CI_Controller
{

    public function __construct()
    {
        parent::__construct();
        $this->load->model('devicemodel');
        $this->load->library('session');
        $this->load->library('encrypt');
    }

    public function adddevice()
    {
        $this->load->helper('form');
        $this->load->library('form_validation');
        if(!$this->session->userdata('user_id'))
         {
           redirect('usercontroller/validateuser','refresh');
         }
            $this->devicemodel->addDevice();
            $this->load->view('devices/addsuccess');
    }

    public function getDeviceData()
    {
        if(!$this->session->userdata('user_id'))
        {
            redirect('usercontroller/validateuser','refresh');
        }
                $data['datareceived']=$this->devicemodel->getData();
                $this->load->view('devices/edit',$data);
    }

    public function add()
    {
        if(!$this->session->userdata('user_id'))
        {
            redirect('usercontroller/validateuser','refresh');
        }
         $this->load->view('devices/add');
    }

    public function updateData()
    {
        $this->devicemodel->updateData();
        $this->load->view('devices/updatesuccess');

    }
    public function stats()
    {
        $data=$this->devicemodel->getStats();
        $this->load->view('devices/stats',$data);

    }

    public function viewind()
    {
        if(!$this->session->userdata('user_id'))
        {
            redirect('usercontroller/validateuser','refresh');
        }
        $data['devices'] = $this->devicemodel->viewind();
        $this->load->view('devices/view', $data);
    }

    public function view()
    {
        $data= $this->devicemodel->view();
        $this->load->view('devices/devices', $data);

    }
}

?>